Skip to content

feat: extract project/environment helpers for multi-project support#657

Merged
DevonFulcher merged 6 commits intomainfrom
df/multiproject-phase1-core
Mar 18, 2026
Merged

feat: extract project/environment helpers for multi-project support#657
DevonFulcher merged 6 commits intomainfrom
df/multiproject-phase1-core

Conversation

@DevonFulcher
Copy link
Collaborator

@DevonFulcher DevonFulcher commented Mar 17, 2026

Why

This is Phase 1 of the multi-project feature, extracting shared helper functions that both Server A (env-var mode) and Server B (multi-project mode) will use. This extraction is the blocking dependency for all subsequent phases.

What

  • New src/dbt_mcp/project/ module with extracted helpers:

    • environment_resolver.pyresolve_environments() (pure logic) and get_environments_for_project() (API + resolution)
    • project_resolver.pyget_all_accounts() and get_all_projects_for_account()
  • Refactored config providers (config_providers.py):

    • Each provider now has only get_config() (existing, unchanged behavior) and a _build_config() static method
    • Removed get_config_for_project(project_id) from all four providers — env resolution belongs in tool functions, not providers, keeping providers stateless
    • Tools in phases 3-6 will call get_environments_for_project() directly at call-time and pass the resolved environment ID to the provider's _build_config() or construct the config override inline
  • Refactored fastapi_app.py:

    • Replaced inline account/project/environment functions with calls to the new extracted helpers
    • Replaced inline environment resolution logic with resolve_environments()
    • No behavior change
  • Added DBT_MCP_MULTI_PROJECT_ENABLED env var check in main.py:

    • When set to true/1/yes, raises NotImplementedError (stub for Server B, implemented in Phase 7)
    • When absent/false, existing behavior unchanged (Server A)
  • Updated existing pagination tests to reference new module paths

Notes

  • All 451 unit tests pass
  • task check passes (lint, format, mypy)
  • No behavior change for existing Server A mode

Drafted by Claude Sonnet 4.6 under the direction of @DevonFulcher

@DevonFulcher DevonFulcher changed the base branch from main to df/migrate-requests-to-httpx March 17, 2026 17:44
@DevonFulcher DevonFulcher force-pushed the df/multiproject-phase1-core branch from 69ce9db to 9afd83f Compare March 17, 2026 17:49
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@DevonFulcher DevonFulcher force-pushed the df/migrate-requests-to-httpx branch from beeaff9 to 4cf34e6 Compare March 17, 2026 17:52
DevonFulcher and others added 4 commits March 17, 2026 12:53
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This will be introduced in the first phase where it has non-empty content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@DevonFulcher DevonFulcher force-pushed the df/multiproject-phase1-core branch from 3a4bf94 to 70b2a82 Compare March 17, 2026 17:54
@DevonFulcher DevonFulcher marked this pull request as ready for review March 17, 2026 18:15
@DevonFulcher DevonFulcher requested review from a team, b-per, jairus-m and jasnonaz as code owners March 17, 2026 18:15
Copy link
Contributor

@alan-andrade alan-andrade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Base automatically changed from df/migrate-requests-to-httpx to main March 18, 2026 15:30
@DevonFulcher DevonFulcher deployed to integration March 18, 2026 16:38 — with GitHub Actions Active
@DevonFulcher DevonFulcher enabled auto-merge (squash) March 18, 2026 16:39
@DevonFulcher DevonFulcher disabled auto-merge March 18, 2026 17:29
@DevonFulcher DevonFulcher merged commit abd2987 into main Mar 18, 2026
11 checks passed
@DevonFulcher DevonFulcher deleted the df/multiproject-phase1-core branch March 18, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants